<template>
  <div id="app">
    <div class="top">
      <el-menu
        :default-active="activeIndex"
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
        v-if="this.$route.meta.showNav"
      >
        <el-menu-item index="1">处理中心</el-menu-item>

        <el-submenu index="11" class="user">
          <template slot="title">
            <i class="el-icon-user"></i>
            {{ adminName }}
          </template>
          <el-menu-item index="11-1" @click="user">个人中心</el-menu-item>
          <el-menu-item index="11-2" @click="quit">退出登陆</el-menu-item>
        </el-submenu>
      </el-menu>
    </div>
    <div class="left">
      <el-menu
        default-active="1"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
        v-if="this.$route.meta.showNav"
      >
        <h1 class="menu-title">预约挂号系统管理员端</h1>
        <el-menu-item index="1" @click="information">
          <i class="el-icon-menu"></i>
          <span slot="title">资讯管理</span>
        </el-menu-item>
        <el-menu-item index="2">
          <i class="el-icon-menu"></i>
          <span slot="title">就诊管理</span>
        </el-menu-item>
        <el-menu-item index="3">
          <i class="el-icon-document"></i>
          <span slot="title">就诊查看</span>
        </el-menu-item>
        <el-menu-item index="4">
          <i class="el-icon-setting"></i>
          <span slot="title">挂号统计</span>
        </el-menu-item>
        <el-menu-item index="5">
          <i class="el-icon-setting"></i>
          <span slot="title">医生管理</span>
        </el-menu-item>
        <el-menu-item index="6">
          <i class="el-icon-setting"></i>
          <span slot="title">号源管理</span>
        </el-menu-item>
        <el-menu-item index="7">
          <i class="el-icon-setting"></i>
          <span slot="title">管理员管理</span>
        </el-menu-item>
      </el-menu>
    </div>

    <router-view @adminApp="adminApp" :adminName="adminName" />
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      activeIndex: "1",
      adminName: "",
      adminPosition: ""
    };
  },
  methods: {
    handleSelect() {},
    index() {
      this.$router.push("/information");
    },

    inHospitalManage() {
      this.$router.push("/inHospitalManage");
    },
    leaveHospital() {
      this.$router.push("/leaveHospitalManage");
    },
    user() {
      this.$router.push("/user");
    },
    information() {
      this.$router.push("/information");
    },
    adminApp(res) {
      this.adminName = res.adminName;
      if (res.position == "管理员") {
        this.adminPosition = 1;
      } else {
        this.adminPosition = 0;
      }
      // console.log(this.adminState);
    },
    quit() {
      this.adminName = "";
      this.adminPosition = "";
      this.$router.push("/");
      this.$message({
        message: "退出登陆成功",
        type: "success"
      });
    }
  }
};
</script>

<style>
.user {
  position: absolute;
  right: 10px;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}
.left {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
}

.el-menu-vertical-demo {
  height: 100%;
}

.menu-title {
  padding-left: 0px;
  font-size: 25px;
  color: aliceblue;
}

.user {
  position: absolute;
  right: 10px;
}
</style>
